home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / nt / emacssrc.zip / EMACSSRC.TAR / emacs-19.17 / src / lread.c < prev    next >
C/C++ Source or Header  |  1993-11-22  |  53KB  |  1,976 lines

  1. /* Lisp parsing and input streams.
  2.    Copyright (C) 1985, 1986, 1987, 1988, 1989,
  3.    1993 Free Software Foundation, Inc.
  4.  
  5. This file is part of GNU Emacs.
  6.  
  7. GNU Emacs is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2, or (at your option)
  10. any later version.
  11.  
  12. GNU Emacs is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with GNU Emacs; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21.  
  22. #include <stdio.h>
  23. #include <sys/types.h>
  24. #include <sys/stat.h>
  25. #ifdef    WINDOWSNT
  26. #include <fcntl.h>
  27. #else
  28. #include <sys/file.h>
  29. #endif /* !WINDOWSNT */
  30. #include <ctype.h>
  31. #include "config.h"
  32. #include "lisp.h"
  33.  
  34. #ifndef standalone
  35. #include "buffer.h"
  36. #include "paths.h"
  37. #include "commands.h"
  38. #include "keyboard.h"
  39. #include "frame.h"
  40. #include "termhooks.h"
  41. #endif
  42.  
  43. #ifdef lint
  44. #include <sys/inode.h>
  45. #endif /* lint */
  46.  
  47. #ifndef X_OK
  48. #define X_OK 01
  49. #endif
  50.  
  51. #ifdef LISP_FLOAT_TYPE
  52. #ifdef STDC_HEADERS
  53. #include <stdlib.h>
  54. #endif
  55. #include <math.h>
  56. #endif /* LISP_FLOAT_TYPE */
  57.  
  58. #ifdef STDC_HEADERS
  59. #include <string.h>
  60. #include <io.h>
  61. #endif
  62. #include "lread_p.h"
  63. #include "intervals_p.h"
  64. #include "xdisp_p.h"
  65. #include "alloca_p.h"
  66. static int readchar _P_((Lisp_Object readcharfun));
  67. static void unreadchar _P_((Lisp_Object readcharfun, int c));
  68. static Lisp_Object load_unwind _P_((Lisp_Object stream));
  69. static int complete_filename_p _P_((Lisp_Object pathname));
  70. static void build_load_history _P_((FILE *stream, Lisp_Object source));
  71. static void readevalloop _P_((Lisp_Object readcharfun, FILE *stream,
  72.                               Lisp_Object sourcename,
  73.                               Lisp_Object (*evalfun)(Lisp_Object val),
  74.                               int printflag));
  75. static Lisp_Object read0 _P_((Lisp_Object readcharfun));
  76. static int read_escape _P_((Lisp_Object readcharfun));
  77. static Lisp_Object read1 _P_((register Lisp_Object readcharfun));
  78. static Lisp_Object read_vector _P_((Lisp_Object readcharfun));
  79. static Lisp_Object read_list _P_((int flag,
  80.                                   register Lisp_Object readcharfun));
  81. static int hash_string _P_((unsigned char *ptr, int len));
  82.  
  83. Lisp_Object Qread_char, Qget_file_char, Qstandard_input, Qcurrent_load_list;
  84. Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist;
  85. Lisp_Object Qascii_character, Qload;
  86.  
  87. extern Lisp_Object Qevent_symbol_element_mask;
  88.  
  89. /* non-zero if inside `load' */
  90. int load_in_progress;
  91.  
  92. /* Search path for files to be loaded. */
  93. Lisp_Object Vload_path;
  94.  
  95. /* This is the user-visible association list that maps features to
  96.    lists of defs in their load files. */
  97. Lisp_Object Vload_history;
  98.  
  99. /* This is useud to build the load history. */
  100. Lisp_Object Vcurrent_load_list;
  101.  
  102. /* File for get_file_char to read from.  Use by load */
  103. static FILE *instream;
  104.  
  105. /* When nonzero, read conses in pure space */
  106. static int read_pure;
  107.  
  108. /* For use within read-from-string (this reader is non-reentrant!!) */
  109. static int read_from_string_index;
  110. static int read_from_string_limit;
  111.  
  112. /* Handle unreading and rereading of characters.
  113.    Write READCHAR to read a character,
  114.    UNREAD(c) to unread c to be read again. */
  115.  
  116. #define READCHAR readchar (readcharfun)
  117. #define UNREAD(c) unreadchar (readcharfun, c)
  118.  
  119. static int
  120. readchar (readcharfun)
  121.      Lisp_Object readcharfun;
  122. {
  123.   Lisp_Object tem;
  124.   register struct buffer *inbuffer;
  125.   register int c, mpos;
  126.  
  127.   if (XTYPE (readcharfun) == Lisp_Buffer)
  128.     {
  129.       inbuffer = XBUFFER (readcharfun);
  130.  
  131.       if (BUF_PT (inbuffer) >= BUF_ZV (inbuffer))
  132.     return -1;
  133.       c = *(unsigned char *) BUF_CHAR_ADDRESS (inbuffer, BUF_PT (inbuffer));
  134.       SET_BUF_PT (inbuffer, BUF_PT (inbuffer) + 1);
  135.  
  136.       return c;
  137.     }
  138.   if (XTYPE (readcharfun) == Lisp_Marker)
  139.     {
  140.       inbuffer = XMARKER (readcharfun)->buffer;
  141.  
  142.       mpos = marker_position (readcharfun);
  143.  
  144.       if (mpos > BUF_ZV (inbuffer) - 1)
  145.     return -1;
  146.       c = *(unsigned char *) BUF_CHAR_ADDRESS (inbuffer, mpos);
  147.       if (mpos != BUF_GPT (inbuffer))
  148.     XMARKER (readcharfun)->bufpos++;
  149.       else
  150.     Fset_marker (readcharfun, make_number (mpos + 1),
  151.              Fmarker_buffer (readcharfun));
  152.       return c;
  153.     }
  154.   if (EQ (readcharfun, Qget_file_char))
  155.     return getc (instream);
  156.  
  157.   if (XTYPE (readcharfun) == Lisp_String)
  158.     {
  159.       register int c;
  160.       /* This used to be return of a conditional expression,
  161.      but that truncated -1 to a char on VMS.  */
  162.       if (read_from_string_index < read_from_string_limit)
  163.     c = XSTRING (readcharfun)->data[read_from_string_index++];
  164.       else
  165.     c = -1;
  166.       return c;
  167.     }
  168.  
  169.   tem = call0 (readcharfun);
  170.  
  171.   if (NILP (tem))
  172.     return -1;
  173.   return XINT (tem);
  174. }
  175.  
  176. /* Unread the character C in the way appropriate for the stream READCHARFUN.
  177.    If the stream is a user function, call it with the char as argument.  */
  178.  
  179. static void
  180. unreadchar (readcharfun, c)
  181.      Lisp_Object readcharfun;
  182.      int c;
  183. {
  184.   if (XTYPE (readcharfun) == Lisp_Buffer)
  185.     {
  186.       if (XBUFFER (readcharfun) == current_buffer)
  187.     SET_PT (point - 1);
  188.       else
  189.     SET_BUF_PT (XBUFFER (readcharfun), BUF_PT (XBUFFER (readcharfun)) - 1);
  190.     }
  191.   else if (XTYPE (readcharfun) == Lisp_Marker)
  192.     XMARKER (readcharfun)->bufpos--;
  193.   else if (XTYPE (readcharfun) == Lisp_String)
  194.     read_from_string_index--;
  195.   else if (EQ (readcharfun, Qget_file_char))
  196.     ungetc (c, instream);
  197.   else
  198.     call1 (readcharfun, make_number (c));
  199. }
  200.  
  201.  
  202. /* get a character from the tty */
  203.  
  204. /* Read input events until we get one that's acceptable for our purposes.
  205.  
  206.    If NO_SWITCH_FRAME is non-zero, switch-frame events are stashed
  207.    until we get a character we like, and then stuffed into
  208.    unread_switch_frame.
  209.  
  210.    If ASCII_REQUIRED is non-zero, we check function key events to see
  211.    if the unmodified version of the symbol has a Qascii_character
  212.    property, and use that character, if present.
  213.  
  214.    If ERROR_NONASCII is non-zero, we signal an error if the input we
  215.    get isn't an ASCII character with modifiers.  If it's zero but
  216.    ASCII_REQUIRED is non-zero, we just re-read until we get an ASCII
  217.    character.  */
  218. Lisp_Object
  219. read_filtered_event (no_switch_frame, ascii_required, error_nonascii)
  220.      int no_switch_frame, ascii_required, error_nonascii;
  221. {
  222. #ifdef standalone
  223.   return make_number (getchar ());
  224. #else
  225.   register Lisp_Object val;
  226.   register Lisp_Object delayed_switch_frame = Qnil;
  227.  
  228.   /* Read until we get an acceptable event.  */
  229.  retry:
  230.   val = read_char (0, 0, 0, Qnil, 0);
  231.  
  232.   /* switch-frame events are put off until after the next ASCII
  233.      character.  This is better than signalling an error just because
  234.      the last characters were typed to a separate minibuffer frame,
  235.      for example.  Eventually, some code which can deal with
  236.      switch-frame events will read it and process it.  */
  237.   if (no_switch_frame
  238.       && EVENT_HAS_PARAMETERS (val)
  239.       && EQ (EVENT_HEAD (val), Qswitch_frame))
  240.     {
  241.       delayed_switch_frame = val;
  242.       goto retry;
  243.     }
  244.  
  245.   if (ascii_required)
  246.     {
  247.       /* Convert certain symbols to their ASCII equivalents.  */
  248.       if (XTYPE (val) == Lisp_Symbol)
  249.     {
  250.       Lisp_Object tem, tem1;
  251.       tem = Fget (val, Qevent_symbol_element_mask);
  252.       if (!NILP (tem))
  253.         {
  254.           tem1 = Fget (Fcar (tem), Qascii_character);
  255.           /* Merge this symbol's modifier bits
  256.          with the ASCII equivalent of its basic code.  */
  257.           if (!NILP (tem1))
  258.         XFASTINT (val) = XINT (tem1) | XINT (Fcar (Fcdr (tem)));
  259.         }
  260.     }
  261.       
  262.       /* If we don't have a character now, deal with it appropriately.  */
  263.       if (XTYPE (val) != Lisp_Int)
  264.     {
  265.       if (error_nonascii)
  266.         {
  267.           unread_command_events = Fcons (val, Qnil);
  268.           error ("Non-character input-event");
  269.         }
  270.       else
  271.         goto retry;
  272.     }
  273.     }
  274.  
  275.   if (! NILP (delayed_switch_frame))
  276.     unread_switch_frame = delayed_switch_frame;
  277.  
  278.   return val;
  279. #endif
  280. }
  281.  
  282. DEFUN ("read-char", Fread_char, Sread_char, 0, 0, 0,
  283.   "Read a character from the command input (keyboard or macro).\n\
  284. It is returned as a number.\n\
  285. If the user generates an event which is not a character (i.e. a mouse\n\
  286. click or function key event), `read-char' signals an error.  As an\n\
  287. exception, switch-frame events are put off until non-ASCII events can\n\
  288. be read.\n\
  289. If you want to read non-character events, or ignore them, call\n\
  290. `read-event' or `read-char-exclusive' instead.")
  291.   ()
  292. {
  293.   return read_filtered_event (1, 1, 1);
  294. }
  295.  
  296. DEFUN ("read-event", Fread_event, Sread_event, 0, 0, 0,
  297.   "Read an event object from the input stream.")
  298.   ()
  299. {
  300.   return read_filtered_event (0, 0, 0);
  301. }
  302.  
  303. DEFUN ("read-char-exclusive", Fread_char_exclusive, Sread_char_exclusive, 0, 0, 0,
  304.   "Read a character from the command input (keyboard or macro).\n\
  305. It is returned as a number.  Non character events are ignored.")
  306.   ()
  307. {
  308.   return read_filtered_event (1, 1, 0);
  309. }
  310.  
  311. DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 0, 0,
  312.   "Don't use this yourself.")
  313.   ()
  314. {
  315.   register Lisp_Object val;
  316.   XSET (val, Lisp_Int, getc (instream));
  317.   return val;
  318. }
  319.  
  320.  
  321. DEFUN ("load", Fload, Sload, 1, 4, 0,
  322.   "Execute a file of Lisp code named FILE.\n\
  323. First try FILE with `.elc' appended, then try with `.el',\n\
  324.  then try FILE unmodified.\n\
  325. This function searches the directories in `load-path'.\n\
  326. If optional second arg NOERROR is non-nil,\n\
  327.  report no error if FILE doesn't exist.\n\
  328. Print messages at start and end of loading unless\n\
  329.  optional third arg NOMESSAGE is non-nil.\n\
  330. If optional fourth arg NOSUFFIX is non-nil, don't try adding\n\
  331.  suffixes `.elc' or `.el' to the specified name FILE.\n\
  332. Return t if file exists.")
  333.   (str, noerror, nomessage, nosuffix)
  334.      Lisp_Object str, noerror, nomessage, nosuffix;
  335. {
  336.   register FILE *stream;
  337.   register int fd = -1;
  338.   register Lisp_Object lispstream;
  339.   register FILE **ptr;
  340.   int count = specpdl_ptr - specpdl;
  341.   Lisp_Object temp;
  342.   struct gcpro gcpro1;
  343.   Lisp_Object found;
  344.   /* 1 means inhibit the message at the beginning.  */
  345.   int nomessage1 = 0;
  346.   Lisp_Object handler;
  347.  
  348.   CHECK_STRING (str, 0);
  349.   str = Fsubstitute_in_file_name (str);
  350.  
  351.   /* If file name is magic, call the handler.  */
  352.   handler = Ffind_file_name_handler (str);
  353.   if (!NILP (handler))
  354.     return call5 (handler, Qload, str, noerror, nomessage, nosuffix);
  355.  
  356.   /* Avoid weird lossage with null string as arg,
  357.      since it would try to load a directory as a Lisp file */
  358.   if (XSTRING (str)->size > 0)
  359.     {
  360.       fd = openp (Vload_path, str, !NILP (nosuffix) ? "" : ".elc:.el:",
  361.           &found, 0);
  362.     }
  363.  
  364.   if (fd < 0)
  365.     {
  366.       if (NILP (noerror))
  367.     while (1)
  368.       Fsignal (Qfile_error, Fcons (build_string ("Cannot open load file"),
  369.                        Fcons (str, Qnil)));
  370.       else
  371.     return Qnil;
  372.     }
  373.  
  374.   if (!bcmp (&(XSTRING (found)->data[XSTRING (found)->size - 4]),
  375.          ".elc", 4))
  376.     {
  377.       struct stat s1, s2;
  378.       int result;
  379.  
  380.       stat (XSTRING (found)->data, &s1);
  381.       XSTRING (found)->data[XSTRING (found)->size - 1] = 0;
  382.       result = stat (XSTRING (found)->data, &s2);
  383.       if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime)
  384.     {
  385.       message ("Source file `%s' newer than byte-compiled file",
  386.            XSTRING (found)->data);
  387.       /* Don't immediately overwrite this message.  */
  388.       if (!noninteractive)
  389.         nomessage1 = 1;
  390.     }
  391.       XSTRING (found)->data[XSTRING (found)->size - 1] = 'c';
  392.     }
  393.  
  394. #ifdef WINDOWSNT
  395.   /*
  396.    * We need binary mode here otherwise the CRT will filter Ctrl-Zs as
  397.    * EOFs, confusing the heck out of emacs.        (voelker)
  398.    */
  399.   stream = _fdopen (fd, "rb");
  400. #else
  401.   stream = fdopen (fd, "r");
  402. #endif /* !WINDOWSNT */
  403.  
  404.   if (stream == 0)
  405.     {
  406.       close (fd);
  407.       error ("Failure to create stdio stream for %s", XSTRING (str)->data);
  408.     }
  409.  
  410.   if (NILP (nomessage) && !nomessage1)
  411.     message ("Loading %s...", XSTRING (str)->data);
  412.  
  413.   GCPRO1 (str);
  414.   /* We may not be able to store STREAM itself as a Lisp_Object pointer
  415.      since that is guaranteed to work only for data that has been malloc'd.
  416.      So malloc a full-size pointer, and record the address of that pointer.  */
  417.   ptr = (FILE **) xmalloc (sizeof (FILE *));
  418.   *ptr = stream;
  419.   XSET (lispstream, Lisp_Internal_Stream, (int) ptr);
  420.   record_unwind_protect (load_unwind, lispstream);
  421.   load_in_progress++;
  422.   readevalloop (Qget_file_char, stream, str, Feval, 0);
  423.   unbind_to (count, Qnil);
  424.  
  425.   /* Run any load-hooks for this file.  */
  426.   temp = Fassoc (str, Vafter_load_alist);
  427.   if (!NILP (temp))
  428.     Fprogn (Fcdr (temp));
  429.   UNGCPRO;
  430.  
  431.   if (!noninteractive && NILP (nomessage))
  432.     message ("Loading %s...done", XSTRING (str)->data);
  433.  
  434.   return Qt;
  435. }
  436.  
  437. static Lisp_Object
  438. load_unwind (stream)  /* used as unwind-protect function in load */
  439.      Lisp_Object stream;
  440. {
  441.   fclose (*(FILE **) XSTRING (stream));
  442.   xfree (XPNTR (stream));
  443.   if (--load_in_progress < 0) load_in_progress = 0;
  444.   return Qnil;
  445. }
  446.  
  447.  
  448. static int
  449. complete_filename_p (pathname)
  450.      Lisp_Object pathname;
  451. {
  452.   register unsigned char *s = XSTRING (pathname)->data;
  453.   return (
  454. #ifdef WINDOWSNT
  455.           *s == '\\' || (s[1] == ':' && s[2] == '\\')
  456. #else /* !WINDOWSNT */
  457.       *s == '/'
  458. #endif /* !WINDOWSNT */
  459. #ifdef ALTOS
  460.       || *s == '@'
  461. #endif
  462. #ifdef VMS
  463.       || index (s, ':')
  464. #endif /* VMS */
  465.       );
  466. }
  467.  
  468. /* Search for a file whose name is STR, looking in directories
  469.    in the Lisp list PATH, and trying suffixes from SUFFIX.
  470.    SUFFIX is a string containing possible suffixes separated by colons.
  471.    On success, returns a file descriptor.  On failure, returns -1.
  472.  
  473.    EXEC_ONLY nonzero means don't open the files,
  474.    just look for one that is executable.  In this case,
  475.    returns 1 on success.
  476.  
  477.    If STOREPTR is nonzero, it points to a slot where the name of
  478.    the file actually found should be stored as a Lisp string.
  479.    Nil is stored there on failure.  */
  480.  
  481. int
  482. openp (path, str, suffix, storeptr, exec_only)
  483.      Lisp_Object path, str;
  484.      char *suffix;
  485.      Lisp_Object *storeptr;
  486.      int exec_only;
  487. {
  488.   register int fd;
  489.   int fn_size = 100;
  490.   char buf[100];
  491.   register char *fn = buf;
  492.   int absolute = 0;
  493.   int want_size;
  494.   register Lisp_Object filename;
  495.   struct stat st;
  496.  
  497.   if (storeptr)
  498.     *storeptr = Qnil;
  499.  
  500.   if (complete_filename_p (str))
  501.     absolute = 1;
  502.  
  503.   for (; !NILP (path); path = Fcdr (path))
  504.     {
  505.       char *nsuffix;
  506.  
  507.       filename = Fexpand_file_name (str, Fcar (path));
  508.       if (!complete_filename_p (filename))
  509.     /* If there are non-absolute elts in PATH (eg ".") */
  510.     /* Of course, this could conceivably lose if luser sets
  511.        default-directory to be something non-absolute... */
  512.     {
  513.       filename = Fexpand_file_name (filename, current_buffer->directory);
  514.       if (!complete_filename_p (filename))
  515.         /* Give up on this path element! */
  516.         continue;
  517.     }
  518.  
  519.       /* Calculate maximum size of any filename made from
  520.      this path element/specified file name and any possible suffix.  */
  521.       want_size = strlen (suffix) + XSTRING (filename)->size + 1;
  522.       if (fn_size < want_size)
  523.     fn = (char *) alloca (fn_size = 100 + want_size);
  524.  
  525.       nsuffix = suffix;
  526.  
  527.       /* Loop over suffixes.  */
  528.       while (1)
  529.     {
  530.       char *esuffix = (char *) index (nsuffix, ':');
  531.       int lsuffix = esuffix ? esuffix - nsuffix : strlen (nsuffix);
  532.  
  533.       /* Concatenate path element/specified name with the suffix.  */
  534.       strncpy (fn, XSTRING (filename)->data, XSTRING (filename)->size);
  535.       fn[XSTRING (filename)->size] = 0;
  536.       if (lsuffix != 0)  /* Bug happens on CCI if lsuffix is 0.  */
  537.         strncat (fn, nsuffix, lsuffix);
  538.  
  539.       /* Ignore file if it's a directory.  */
  540.       if (stat (fn, &st) >= 0
  541.           && (st.st_mode & S_IFMT) != S_IFDIR)
  542.         {
  543.           /* Check that we can access or open it.  */
  544.           if (exec_only)
  545.         fd = (access (fn, X_OK) == 0) ? 1 : -1;
  546.           else {
  547. #ifdef WINDOWSNT
  548.         /*
  549.          * Ok, time to get hackish.  NT's CRT will automatically
  550.          * convert Ctrl-Zs to EOFs, horribly confusing emacs,
  551.          * unless the file is opened in binary mode.  However,
  552.          * if we open the file in binary, then we also lose the
  553.          * CRT CR-LF -> CR filtering.  Compromise -- if the
  554.          * suffix is ".elc", then use binary mode;  otherwise,
  555.          * open it with filtering.        (voelker)
  556.          */
  557.         if (lsuffix == 3 && !strncmp(".el", nsuffix, 3)) {
  558.             fd = open (fn, 0, 0);
  559.         } else {
  560.             // Be conservative towards opening using binary flag.
  561.             fd = open (fn, _O_BINARY, 0);
  562.         }
  563. #else
  564.         fd = open (fn, 0, 0);
  565. #endif /* !WINDOWSNT */
  566.           }
  567.  
  568.           if (fd >= 0)
  569.         {
  570.           /* We succeeded; return this descriptor and filename.  */
  571.           if (storeptr)
  572.             *storeptr = build_string (fn);
  573.           return fd;
  574.         }
  575.         }
  576.  
  577.       /* Advance to next suffix.  */
  578.       if (esuffix == 0)
  579.         break;
  580.       nsuffix += lsuffix + 1;
  581.     }
  582.       if (absolute) return -1;
  583.     }
  584.  
  585.   return -1;
  586. }
  587.  
  588.  
  589. /* Merge the list we've accumulated of globals from the current input source
  590.    into the load_history variable.  The details depend on whether
  591.    the source has an associated file name or not. */
  592.  
  593. static void
  594. build_load_history (stream, source)
  595.      FILE *stream;
  596.      Lisp_Object source;
  597. {
  598.   register Lisp_Object tail, prev, newelt;
  599.   register Lisp_Object tem, tem2;
  600.   register int foundit, loading;
  601.  
  602.   /* Don't bother recording anything for preloaded files.  */
  603.   if (!NILP (Vpurify_flag))
  604.     return;
  605.  
  606.   loading = stream || !NARROWED;
  607.  
  608.   tail = Vload_history;
  609.   prev = Qnil;
  610.   foundit = 0;
  611.   while (!NILP (tail))
  612.     {
  613.       tem = Fcar (tail);
  614.  
  615.       /* Find the feature's previous assoc list... */
  616.       if (!NILP (Fequal (source, Fcar (tem))))
  617.     {
  618.       foundit = 1;
  619.  
  620.       /*  If we're loading, remove it. */
  621.       if (loading)
  622.         {      
  623.           if (NILP (prev))
  624.         Vload_history = Fcdr (tail);
  625.           else
  626.         Fsetcdr (prev, Fcdr (tail));
  627.         }
  628.  
  629.       /*  Otherwise, cons on new symbols that are not already members.  */
  630.       else
  631.         {
  632.           tem2 = Vcurrent_load_list;
  633.  
  634.           while (CONSP (tem2))
  635.         {
  636.           newelt = Fcar (tem2);
  637.  
  638.           if (NILP (Fmemq (newelt, tem)))
  639.             Fsetcar (tail, Fcons (Fcar (tem),
  640.                       Fcons (newelt, Fcdr (tem))));
  641.  
  642.           tem2 = Fcdr (tem2);
  643.           QUIT;
  644.         }
  645.         }
  646.     }
  647.       else
  648.     prev = tail;
  649.       tail = Fcdr (tail);
  650.       QUIT;
  651.     }
  652.  
  653.   /* If we're loading, cons the new assoc onto the front of load-history,
  654.      the most-recently-loaded position.  Also do this if we didn't find
  655.      an existing member for the current source.  */
  656.   if (loading || !foundit)
  657.     Vload_history = Fcons (Fnreverse (Vcurrent_load_list),
  658.                Vload_history);
  659. }
  660.  
  661. Lisp_Object
  662. unreadpure (dummy)    /* Used as unwind-protect function in readevalloop */
  663.     Lisp_Object dummy;
  664. {
  665.   read_pure = 0;
  666.   return Qnil;
  667. }
  668.  
  669. static void
  670. readevalloop (readcharfun, stream, sourcename, evalfun, printflag)
  671.      Lisp_Object readcharfun;
  672.      FILE *stream;
  673.      Lisp_Object sourcename;
  674.      Lisp_Object (*evalfun) _P_((Lisp_Object val));
  675.      int printflag;
  676. {
  677.   register int c;
  678.   register Lisp_Object val;
  679.   int count = specpdl_ptr - specpdl;
  680.   struct gcpro gcpro1;
  681.  
  682.   specbind (Qstandard_input, readcharfun);
  683.   specbind (Qcurrent_load_list, Qnil);
  684.  
  685.   GCPRO1 (sourcename);
  686.  
  687.   LOADHIST_ATTACH (sourcename);
  688.  
  689.   while (1)
  690.     {
  691.       instream = stream;
  692.       c = READCHAR;
  693.       if (c == ';')
  694.     {
  695.       while ((c = READCHAR) != '\n' && c != -1);
  696.       continue;
  697.     }
  698.       if (c < 0) break;
  699.       if (c == ' ' || c == '\t' || c == '\n'
  700. #ifdef    WINDOWSNT
  701.       || c == '\r'
  702. #endif
  703.       || c == '\f') continue;
  704.  
  705.       if (!NILP (Vpurify_flag) && c == '(')
  706.     {
  707.       record_unwind_protect (unreadpure, Qnil);
  708.       val = read_list (-1, readcharfun);
  709.       unbind_to (count + 1, Qnil);
  710.     }
  711.       else
  712.     {
  713.       UNREAD (c);
  714.       val = read0 (readcharfun);
  715.     }
  716.  
  717.       val = (*evalfun) (val);
  718.       if (printflag)
  719.     {
  720.       Vvalues = Fcons (val, Vvalues);
  721.       if (EQ (Vstandard_output, Qt))
  722.         Fprin1 (val, Qnil);
  723.       else
  724.         Fprint (val, Qnil);
  725.     }
  726.     }
  727.  
  728.   build_load_history (stream, sourcename);
  729.   UNGCPRO;
  730.  
  731.   unbind_to (count, Qnil);
  732. }
  733.  
  734. #ifndef standalone
  735.  
  736. DEFUN ("eval-buffer", Feval_buffer, Seval_buffer, 0, 2, "",
  737.   "Execute the current buffer as Lisp code.\n\
  738. Programs can pass two arguments, BUFFER and PRINTFLAG.\n\
  739. BUFFER is the buffer to evaluate (nil means use current buffer).\n\
  740. PRINTFLAG controls printing of output:\n\
  741. nil means discard it; anything else is stream for print.\n\
  742. \n\
  743. If there is no error, point does not move.  If there is an error,\n\
  744. point remains at the end of the last character read from the buffer.")
  745.   (bufname, printflag)
  746.      Lisp_Object bufname, printflag;
  747. {
  748.   int count = specpdl_ptr - specpdl;
  749.   Lisp_Object tem, buf;
  750.  
  751.   if (NILP (bufname))
  752.     buf = Fcurrent_buffer ();
  753.   else
  754.     buf = Fget_buffer (bufname);
  755.   if (NILP (buf))
  756.     error ("No such buffer.");
  757.  
  758.   if (NILP (printflag))
  759.     tem = Qsymbolp;
  760.   else
  761.     tem = printflag;
  762.   specbind (Qstandard_output, tem);
  763.   record_unwind_protect (save_excursion_restore, save_excursion_save ());
  764.   BUF_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
  765.   readevalloop (buf, 0, XBUFFER (buf)->filename, Feval, !NILP (printflag));
  766.   unbind_to (count, Qnil);
  767.  
  768.   return Qnil;
  769. }
  770.  
  771. #if 0
  772. DEFUN ("eval-current-buffer", Feval_current_buffer, Seval_current_buffer, 0, 1, "",
  773.   "Execute the current buffer as Lisp code.\n\
  774. Programs can pass argument PRINTFLAG which controls printing of output:\n\
  775. nil means discard it; anything else is stream for print.\n\
  776. \n\
  777. If there is no error, point does not move.  If there is an error,\n\
  778. point remains at the end of the last character read from the buffer.")
  779.   (printflag)
  780.      Lisp_Object printflag;
  781. {
  782.   int count = specpdl_ptr - specpdl;
  783.   Lisp_Object tem, cbuf;
  784.  
  785.   cbuf = Fcurrent_buffer ()
  786.  
  787.   if (NILP (printflag))
  788.     tem = Qsymbolp;
  789.   else
  790.     tem = printflag;
  791.   specbind (Qstandard_output, tem);
  792.   record_unwind_protect (save_excursion_restore, save_excursion_save ());
  793.   SET_PT (BEGV);
  794.   readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval, !NILP (printflag));
  795.   return unbind_to (count, Qnil);
  796. }
  797. #endif
  798.  
  799. DEFUN ("eval-region", Feval_region, Seval_region, 2, 3, "r",
  800.   "Execute the region as Lisp code.\n\
  801. When called from programs, expects two arguments,\n\
  802. giving starting and ending indices in the current buffer\n\
  803. of the text to be executed.\n\
  804. Programs can pass third argument PRINTFLAG which controls output:\n\
  805. nil means discard it; anything else is stream for printing it.\n\
  806. \n\
  807. If there is no error, point does not move.  If there is an error,\n\
  808. point remains at the end of the last character read from the buffer.")
  809.   (b, e, printflag)
  810.      Lisp_Object b, e, printflag;
  811. {
  812.   int count = specpdl_ptr - specpdl;
  813.   Lisp_Object tem, cbuf;
  814.  
  815.   cbuf = Fcurrent_buffer ();
  816.  
  817.   if (NILP (printflag))
  818.     tem = Qsymbolp;
  819.   else
  820.     tem = printflag;
  821.   specbind (Qstandard_output, tem);
  822.  
  823.   if (NILP (printflag))
  824.     record_unwind_protect (save_excursion_restore, save_excursion_save ());
  825.   record_unwind_protect (save_restriction_restore, save_restriction_save ());
  826.  
  827.   /* This both uses b and checks its type.  */
  828.   Fgoto_char (b);
  829.   Fnarrow_to_region (make_number (BEGV), e);
  830.   readevalloop (cbuf, 0, XBUFFER (cbuf)->filename, Feval, !NILP (printflag));
  831.  
  832.   return unbind_to (count, Qnil);
  833. }
  834.  
  835. #endif /* standalone */
  836.  
  837. DEFUN ("read", Fread, Sread, 0, 1, 0,
  838.   "Read one Lisp expression as text from STREAM, return as Lisp object.\n\
  839. If STREAM is nil, use the value of `standard-input' (which see).\n\
  840. STREAM or the value of `standard-input' may be:\n\
  841.  a buffer (read from point and advance it)\n\
  842.  a marker (read from where it points and advance it)\n\
  843.  a function (call it with no arguments for each character,\n\
  844.      call it with a char as argument to push a char back)\n\
  845.  a string (takes text from string, starting at the beginning)\n\
  846.  t (read text line using minibuffer and use it).")
  847.   (readcharfun)
  848.      Lisp_Object readcharfun;
  849. {
  850.   extern Lisp_Object Fread_minibuffer ();
  851.  
  852.   if (NILP (readcharfun))
  853.     readcharfun = Vstandard_input;
  854.   if (EQ (readcharfun, Qt))
  855.     readcharfun = Qread_char;
  856.  
  857. #ifndef standalone
  858.   if (EQ (readcharfun, Qread_char))
  859.     return Fread_minibuffer (build_string ("Lisp expression: "), Qnil);
  860. #endif
  861.  
  862.   if (XTYPE (readcharfun) == Lisp_String)
  863.     return Fcar (Fread_from_string (readcharfun, Qnil, Qnil));
  864.  
  865.   return read0 (readcharfun);
  866. }
  867.  
  868. DEFUN ("read-from-string", Fread_from_string, Sread_from_string, 1, 3, 0,
  869.   "Read one Lisp expression which is represented as text by STRING.\n\
  870. Returns a cons: (OBJECT-READ . FINAL-STRING-INDEX).\n\
  871. START and END optionally delimit a substring of STRING from which to read;\n\
  872.  they default to 0 and (length STRING) respectively.")
  873.   (string, start, end)
  874.      Lisp_Object string, start, end;
  875. {
  876.   int startval, endval;
  877.   Lisp_Object tem;
  878.  
  879.   CHECK_STRING (string,0);
  880.  
  881.   if (NILP (end))
  882.     endval = XSTRING (string)->size;
  883.   else
  884.     { CHECK_NUMBER (end,2);
  885.       endval = XINT (end);
  886.       if (endval < 0 || endval > XSTRING (string)->size)
  887.     args_out_of_range (string, end);
  888.     }
  889.  
  890.   if (NILP (start))
  891.     startval = 0;
  892.   else
  893.     { CHECK_NUMBER (start,1);
  894.       startval = XINT (start);
  895.       if (startval < 0 || startval > endval)
  896.     args_out_of_range (string, start);
  897.     }
  898.  
  899.   read_from_string_index = startval;
  900.   read_from_string_limit = endval;
  901.  
  902.   tem = read0 (string);
  903.   return Fcons (tem, make_number (read_from_string_index));
  904. }
  905.  
  906. /* Use this for recursive reads, in contexts where internal tokens are not allowed. */
  907.  
  908. static Lisp_Object
  909. read0 (readcharfun)
  910.      Lisp_Object readcharfun;
  911. {
  912.   register Lisp_Object val;
  913.   char c;
  914.  
  915.   val = read1 (readcharfun);
  916.   if (XTYPE (val) == Lisp_Internal)
  917.     {
  918.       c = XINT (val);
  919.       return Fsignal (Qinvalid_read_syntax, Fcons (make_string (&c, 1), Qnil));
  920.     }
  921.  
  922.   return val;
  923. }
  924.  
  925. static int read_buffer_size;
  926. static char *read_buffer;
  927.  
  928. static int
  929. read_escape (readcharfun)
  930.      Lisp_Object readcharfun;
  931. {
  932.   register int c = READCHAR;
  933.   switch (c)
  934.     {
  935.     case 'a':
  936.       return '\007';
  937.     case 'b':
  938.       return '\b';
  939.     case 'd':
  940.       return 0177;
  941.     case 'e':
  942.       return 033;
  943.     case 'f':
  944.       return '\f';
  945.     case 'n':
  946.       return '\n';
  947.     case 'r':
  948.       return '\r';
  949.     case 't':
  950.       return '\t';
  951.     case 'v':
  952.       return '\v';
  953.     case '\n':
  954.       return -1;
  955.  
  956.     case 'M':
  957.       c = READCHAR;
  958.       if (c != '-')
  959.     error ("Invalid escape character syntax");
  960.       c = READCHAR;
  961.       if (c == '\\')
  962.     c = read_escape (readcharfun);
  963.       return c | meta_modifier;
  964.  
  965.     case 'S':
  966.       c = READCHAR;
  967.       if (c != '-')
  968.     error ("Invalid escape character syntax");
  969.       c = READCHAR;
  970.       if (c == '\\')
  971.     c = read_escape (readcharfun);
  972.       return c | shift_modifier;
  973.  
  974.     case 'H':
  975.       c = READCHAR;
  976.       if (c != '-')
  977.     error ("Invalid escape character syntax");
  978.       c = READCHAR;
  979.       if (c == '\\')
  980.     c = read_escape (readcharfun);
  981.       return c | hyper_modifier;
  982.  
  983.     case 'A':
  984.       c = READCHAR;
  985.       if (c != '-')
  986.     error ("Invalid escape character syntax");
  987.       c = READCHAR;
  988.       if (c == '\\')
  989.     c = read_escape (readcharfun);
  990.       return c | alt_modifier;
  991.  
  992.     case 's':
  993.       c = READCHAR;
  994.       if (c != '-')
  995.     error ("Invalid escape character syntax");
  996.       c = READCHAR;
  997.       if (c == '\\')
  998.     c = read_escape (readcharfun);
  999.       return c | super_modifier;
  1000.  
  1001.     case 'C':
  1002.       c = READCHAR;
  1003.       if (c != '-')
  1004.     error ("Invalid escape character syntax");
  1005.     case '^':
  1006.       c = READCHAR;
  1007.       if (c == '\\')
  1008.     c = read_escape (readcharfun);
  1009.       if ((c & 0177) == '?')
  1010.     return 0177 | c;
  1011.       /* ASCII control chars are made from letters (both cases),
  1012.      as well as the non-letters within 0100...0137.  */
  1013.       else if ((c & 0137) >= 0101 && (c & 0137) <= 0132)
  1014.     return (c & (037 | ~0177));
  1015.       else if ((c & 0177) >= 0100 && (c & 0177) <= 0137)
  1016.     return (c & (037 | ~0177));
  1017.       else
  1018.     return c | ctrl_modifier;
  1019.  
  1020.     case '0':
  1021.     case '1':
  1022.     case '2':
  1023.     case '3':
  1024.     case '4':
  1025.     case '5':
  1026.     case '6':
  1027.     case '7':
  1028.       /* An octal escape, as in ANSI C.  */
  1029.       {
  1030.     register int i = c - '0';
  1031.     register int count = 0;
  1032.     while (++count < 3)
  1033.       {
  1034.         if ((c = READCHAR) >= '0' && c <= '7')
  1035.           {
  1036.         i *= 8;
  1037.         i += c - '0';
  1038.           }
  1039.         else
  1040.           {
  1041.         UNREAD (c);
  1042.         break;
  1043.           }
  1044.       }
  1045.     return i;
  1046.       }
  1047.  
  1048.     case 'x':
  1049.       /* A hex escape, as in ANSI C.  */
  1050.       {
  1051.     int i = 0;
  1052.     while (1)
  1053.       {
  1054.         c = READCHAR;
  1055.         if (c >= '0' && c <= '9')
  1056.           {
  1057.         i *= 16;
  1058.         i += c - '0';
  1059.           }
  1060.         else if ((c >= 'a' && c <= 'f')
  1061.              || (c >= 'A' && c <= 'F'))
  1062.           {
  1063.         i *= 16;
  1064.         if (c >= 'a' && c <= 'f')
  1065.           i += c - 'a' + 10;
  1066.         else
  1067.           i += c - 'A' + 10;
  1068.           }
  1069.         else
  1070.           {
  1071.         UNREAD (c);
  1072.         break;
  1073.           }
  1074.       }
  1075.     return i;
  1076.       }
  1077.  
  1078.     default:
  1079.       return c;
  1080.     }
  1081. }
  1082.  
  1083. static Lisp_Object
  1084. read1 (readcharfun)
  1085.      register Lisp_Object readcharfun;
  1086. {
  1087.   register int c;
  1088.  
  1089.  retry:
  1090.  
  1091.   c = READCHAR;
  1092.   if (c < 0) return Fsignal (Qend_of_file, Qnil);
  1093.  
  1094.   switch (c)
  1095.     {
  1096.     case '(':
  1097.       return read_list (0, readcharfun);
  1098.  
  1099.     case '[':
  1100.       return read_vector (readcharfun);
  1101.  
  1102.     case ')':
  1103.     case ']':
  1104.       {
  1105.     register Lisp_Object val;
  1106.     XSET (val, Lisp_Internal, c);
  1107.     return val;
  1108.       }
  1109.  
  1110.     case '#':
  1111.       c = READCHAR;
  1112.       if (c == '[')
  1113.     {
  1114.       /* Accept compiled functions at read-time so that we don't have to
  1115.          build them using function calls.  */
  1116.       Lisp_Object tmp;
  1117.       tmp = read_vector (readcharfun);
  1118.       return Fmake_byte_code (XVECTOR (tmp)->size,
  1119.                   XVECTOR (tmp)->contents);
  1120.     }
  1121. #ifdef USE_TEXT_PROPERTIES
  1122.       if (c == '(')
  1123.     {
  1124.       Lisp_Object tmp;
  1125.       struct gcpro gcpro1;
  1126.  
  1127.       /* Read the string itself.  */
  1128.       tmp = read1 (readcharfun);
  1129.       if (XTYPE (tmp) != Lisp_String)
  1130.         Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil));
  1131.       GCPRO1 (tmp);
  1132.       /* Read the intervals and their properties.  */
  1133.       while (1)
  1134.         {
  1135.           Lisp_Object beg, end, plist;
  1136.  
  1137.           beg = read1 (readcharfun);
  1138.           if (XTYPE (beg) == Lisp_Internal)
  1139.         {
  1140.           if (XINT (beg) == ')')
  1141.             break;
  1142.           Fsignal (Qinvalid_read_syntax, Fcons (make_string ("invalid string property list", 28), Qnil));
  1143.         }
  1144.           end = read1 (readcharfun);
  1145.           if (XTYPE (end) == Lisp_Internal)
  1146.         Fsignal (Qinvalid_read_syntax,
  1147.              Fcons (make_string ("invalid string property list", 28), Qnil));
  1148.         
  1149.           plist = read1 (readcharfun);
  1150.           if (XTYPE (plist) == Lisp_Internal)
  1151.         Fsignal (Qinvalid_read_syntax,
  1152.              Fcons (make_string ("invalid string property list", 28), Qnil));
  1153.           Fset_text_properties (beg, end, plist, tmp);
  1154.         }
  1155.       UNGCPRO;
  1156.       return tmp;
  1157.     }
  1158. #endif
  1159.       UNREAD (c);
  1160.       Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil));
  1161.  
  1162.     case ';':
  1163.       while ((c = READCHAR) >= 0 && c != '\n');
  1164.       goto retry;
  1165.  
  1166.     case '\'':
  1167.       {
  1168.     return Fcons (Qquote, Fcons (read0 (readcharfun), Qnil));
  1169.       }
  1170.  
  1171.     case '?':
  1172.       {
  1173.     register Lisp_Object val;
  1174.  
  1175.     c = READCHAR;
  1176.     if (c < 0) return Fsignal (Qend_of_file, Qnil);
  1177.  
  1178.     if (c == '\\')
  1179.       XSET (val, Lisp_Int, read_escape (readcharfun));
  1180.     else
  1181.       XSET (val, Lisp_Int, c);
  1182.  
  1183.     return val;
  1184.       }
  1185.  
  1186.     case '\"':
  1187.       {
  1188.     register char *p = read_buffer;
  1189.     register char *end = read_buffer + read_buffer_size;
  1190.     register int c;
  1191.     int cancel = 0;
  1192.  
  1193.     while ((c = READCHAR) >= 0
  1194.            && c != '\"')
  1195.       {
  1196.         if (p == end)
  1197.           {
  1198.         char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2);
  1199.         p += new - read_buffer;
  1200.         read_buffer += new - read_buffer;
  1201.         end = read_buffer + read_buffer_size;
  1202.           }
  1203.         if (c == '\\')
  1204.           c = read_escape (readcharfun);
  1205.         /* c is -1 if \ newline has just been seen */
  1206.         if (c == -1)
  1207.           {
  1208.         if (p == read_buffer)
  1209.           cancel = 1;
  1210.           }
  1211.         else if (c & CHAR_META)
  1212.           /* Move the meta bit to the right place for a string.  */
  1213.           *p++ = (c & ~CHAR_META) | 0x80;
  1214.         else
  1215.           *p++ = c;
  1216.       }
  1217.     if (c < 0) return Fsignal (Qend_of_file, Qnil);
  1218.  
  1219.     /* If purifying, and string starts with \ newline,
  1220.        return zero instead.  This is for doc strings
  1221.        that we are really going to find in etc/DOC.nn.nn  */
  1222.     if (!NILP (Vpurify_flag) && NILP (Vdoc_file_name) && cancel)
  1223.       return make_number (0);
  1224.  
  1225.     if (read_pure)
  1226.       return make_pure_string (read_buffer, p - read_buffer);
  1227.     else
  1228.       return make_string (read_buffer, p - read_buffer);
  1229.       }
  1230.  
  1231.     case '.':
  1232.       {
  1233. #ifdef LISP_FLOAT_TYPE
  1234.     /* If a period is followed by a number, then we should read it
  1235.        as a floating point number.  Otherwise, it denotes a dotted
  1236.        pair.  */
  1237.     int next_char = READCHAR;
  1238.     UNREAD (next_char);
  1239.  
  1240.     if (! isdigit (next_char))
  1241. #endif
  1242.       {
  1243.         register Lisp_Object val;
  1244.         XSET (val, Lisp_Internal, c);
  1245.         return val;
  1246.       }
  1247.  
  1248.     /* Otherwise, we fall through!  Note that the atom-reading loop
  1249.        below will now loop at least once, assuring that we will not
  1250.        try to UNREAD two characters in a row.  */
  1251.       }
  1252.     default:
  1253.       if (c <= 040) goto retry;
  1254.       {
  1255.     register char *p = read_buffer;
  1256.  
  1257.     {
  1258.       register char *end = read_buffer + read_buffer_size;
  1259.  
  1260.       while (c > 040 && 
  1261.          !(c == '\"' || c == '\'' || c == ';' || c == '?'
  1262.            || c == '(' || c == ')'
  1263. #ifndef LISP_FLOAT_TYPE
  1264.            /* If we have floating-point support, then we need
  1265.               to allow <digits><dot><digits>.  */
  1266.            || c =='.'
  1267. #endif /* not LISP_FLOAT_TYPE */
  1268.            || c == '[' || c == ']' || c == '#'
  1269.            ))
  1270.         {
  1271.           if (p == end)
  1272.         {
  1273.           register char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2);
  1274.           p += new - read_buffer;
  1275.           read_buffer += new - read_buffer;
  1276.           end = read_buffer + read_buffer_size;
  1277.         }
  1278.           if (c == '\\')
  1279.         c = READCHAR;
  1280.           *p++ = c;
  1281.           c = READCHAR;
  1282.         }
  1283.  
  1284.       if (p == end)
  1285.         {
  1286.           char *new = (char *) xrealloc (read_buffer, read_buffer_size *= 2);
  1287.           p += new - read_buffer;
  1288.           read_buffer += new - read_buffer;
  1289. /*          end = read_buffer + read_buffer_size;  */
  1290.         }
  1291.       *p = 0;
  1292.       if (c >= 0)
  1293.         UNREAD (c);
  1294.     }
  1295.  
  1296.     /* Is it an integer? */
  1297.     {
  1298.       register char *p1;
  1299.       register Lisp_Object val;
  1300.       p1 = read_buffer;
  1301.       if (*p1 == '+' || *p1 == '-') p1++;
  1302.       if (p1 != p)
  1303.         {
  1304.           while (p1 != p && (c = *p1) >= '0' && c <= '9') p1++;
  1305. #ifdef LISP_FLOAT_TYPE
  1306.           /* Integers can have trailing decimal points.  */
  1307.           if (p1 > read_buffer && p1 < p && *p1 == '.') p1++;
  1308. #endif
  1309.           if (p1 == p)
  1310.         /* It is an integer. */
  1311.         {
  1312. #ifdef LISP_FLOAT_TYPE
  1313.           if (p1[-1] == '.')
  1314.             p1[-1] = '\0';
  1315. #endif
  1316.           XSET (val, Lisp_Int, atoi (read_buffer));
  1317.           return val;
  1318.         }
  1319.         }
  1320. #ifdef LISP_FLOAT_TYPE
  1321.       if (isfloat_string (read_buffer))
  1322.         return make_float (atof (read_buffer));
  1323. #endif
  1324.     }
  1325.  
  1326.     return intern (read_buffer);
  1327.       }
  1328.     }
  1329. }
  1330.  
  1331. #ifdef LISP_FLOAT_TYPE
  1332.  
  1333. #define LEAD_INT 1
  1334. #define DOT_CHAR 2
  1335. #define TRAIL_INT 4
  1336. #define E_CHAR 8
  1337. #define EXP_INT 16
  1338.  
  1339. int
  1340. isfloat_string (cp)
  1341.      register char *cp;
  1342. {
  1343.   register state;
  1344.   
  1345.   state = 0;
  1346.   if (*cp == '+' || *cp == '-')
  1347.     cp++;
  1348.  
  1349.   if (isdigit(*cp))
  1350.     {
  1351.       state |= LEAD_INT;
  1352.       while (isdigit (*cp))
  1353.     cp ++;
  1354.     }
  1355.   if (*cp == '.')
  1356.     {
  1357.       state |= DOT_CHAR;
  1358.       cp++;
  1359.     }
  1360.   if (isdigit(*cp))
  1361.     {
  1362.       state |= TRAIL_INT;
  1363.       while (isdigit (*cp))
  1364.     cp++;
  1365.     }
  1366.   if (*cp == 'e')
  1367.     {
  1368.       state |= E_CHAR;
  1369.       cp++;
  1370.     }
  1371.   if ((*cp == '+') || (*cp == '-'))
  1372.     cp++;
  1373.  
  1374.   if (isdigit (*cp))
  1375.     {
  1376.       state |= EXP_INT;
  1377.       while (isdigit (*cp))
  1378.     cp++;
  1379.     }
  1380.   return (*cp == 0
  1381.       && (state == (LEAD_INT|DOT_CHAR|TRAIL_INT)
  1382.           || state == (DOT_CHAR|TRAIL_INT)
  1383.           || state == (LEAD_INT|E_CHAR|EXP_INT)
  1384.           || state == (LEAD_INT|DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT)
  1385.           || state == (DOT_CHAR|TRAIL_INT|E_CHAR|EXP_INT)));
  1386. }
  1387. #endif /* LISP_FLOAT_TYPE */
  1388.  
  1389. static Lisp_Object
  1390. read_vector (readcharfun)
  1391.      Lisp_Object readcharfun;
  1392. {
  1393.   register int i;
  1394.   register int size;
  1395.   register Lisp_Object *ptr;
  1396.   register Lisp_Object tem, vector;
  1397.   register struct Lisp_Cons *otem;
  1398.   Lisp_Object len;
  1399.  
  1400.   tem = read_list (1, readcharfun);
  1401.   len = Flength (tem);
  1402.   vector = (read_pure ? make_pure_vector (XINT (len)) : Fmake_vector (len, Qnil));
  1403.  
  1404.  
  1405.   size = XVECTOR (vector)->size;
  1406.   ptr = XVECTOR (vector)->contents;
  1407.   for (i = 0; i < size; i++)
  1408.     {
  1409.       ptr[i] = read_pure ? Fpurecopy (Fcar (tem)) : Fcar (tem);
  1410.       otem = XCONS (tem);
  1411.       tem = Fcdr (tem);
  1412.       free_cons (otem);
  1413.     }
  1414.   return vector;
  1415. }
  1416.   
  1417. /* flag = 1 means check for ] to terminate rather than ) and .
  1418.    flag = -1 means check for starting with defun
  1419.     and make structure pure.  */
  1420.  
  1421. static Lisp_Object
  1422. read_list (flag, readcharfun)
  1423.      int flag;
  1424.      register Lisp_Object readcharfun;
  1425. {
  1426.   /* -1 means check next element for defun,
  1427.      0 means don't check,
  1428.      1 means already checked and found defun. */
  1429.   int defunflag = flag < 0 ? -1 : 0;
  1430.   Lisp_Object val, tail;
  1431.   register Lisp_Object elt, tem;
  1432.   struct gcpro gcpro1, gcpro2;
  1433.  
  1434.   val = Qnil;
  1435.   tail = Qnil;
  1436.  
  1437.   while (1)
  1438.     {
  1439.       GCPRO2 (val, tail);
  1440.       elt = read1 (readcharfun);
  1441.       UNGCPRO;
  1442.       if (XTYPE (elt) == Lisp_Internal)
  1443.     {
  1444.       if (flag > 0)
  1445.         {
  1446.           if (XINT (elt) == ']')
  1447.         return val;
  1448.           return Fsignal (Qinvalid_read_syntax, Fcons (make_string (") or . in a vector", 18), Qnil));
  1449.         }
  1450.       if (XINT (elt) == ')')
  1451.         return val;
  1452.       if (XINT (elt) == '.')
  1453.         {
  1454.           GCPRO2 (val, tail);
  1455.           if (!NILP (tail))
  1456.         XCONS (tail)->cdr = read0 (readcharfun);
  1457.           else
  1458.         val = read0 (readcharfun);
  1459.           elt = read1 (readcharfun);
  1460.           UNGCPRO;
  1461.           if (XTYPE (elt) == Lisp_Internal && XINT (elt) == ')')
  1462.         return val;
  1463.           return Fsignal (Qinvalid_read_syntax, Fcons (make_string (". in wrong context", 18), Qnil));
  1464.         }
  1465.       return Fsignal (Qinvalid_read_syntax, Fcons (make_string ("] in a list", 11), Qnil));
  1466.     }
  1467.       tem = (read_pure && flag <= 0
  1468.          ? pure_cons (elt, Qnil)
  1469.          : Fcons (elt, Qnil));
  1470.       if (!NILP (tail))
  1471.     XCONS (tail)->cdr = tem;
  1472.       else
  1473.     val = tem;
  1474.       tail = tem;
  1475.       if (defunflag < 0)
  1476.     defunflag = EQ (elt, Qdefun);
  1477.       else if (defunflag > 0)
  1478.     read_pure = 1;
  1479.     }
  1480. }
  1481.  
  1482. Lisp_Object Vobarray;
  1483. Lisp_Object initial_obarray;
  1484.  
  1485. Lisp_Object
  1486. check_obarray (obarray)
  1487.      Lisp_Object obarray;
  1488. {
  1489.   while (XTYPE (obarray) != Lisp_Vector || XVECTOR (obarray)->size == 0)
  1490.     {
  1491.       /* If Vobarray is now invalid, force it to be valid.  */
  1492.       if (EQ (Vobarray, obarray)) Vobarray = initial_obarray;
  1493.  
  1494.       obarray = wrong_type_argument (Qvectorp, obarray);
  1495.     }
  1496.   return obarray;
  1497. }
  1498.  
  1499. Lisp_Object
  1500. intern (str)
  1501.      char *str;
  1502. {
  1503.   Lisp_Object tem;
  1504.   int len = strlen (str);
  1505.   Lisp_Object obarray = Vobarray;
  1506.  
  1507.   if (XTYPE (obarray) != Lisp_Vector || XVECTOR (obarray)->size == 0)
  1508.     obarray = check_obarray (obarray);
  1509.   tem = oblookup (obarray, str, len);
  1510.   if (XTYPE (tem) == Lisp_Symbol)
  1511.     return tem;
  1512.   return Fintern ((!NILP (Vpurify_flag)
  1513.            ? make_pure_string (str, len)
  1514.            : make_string (str, len)),
  1515.           obarray);
  1516. }
  1517.  
  1518. DEFUN ("intern", Fintern, Sintern, 1, 2, 0,
  1519.   "Return the canonical symbol whose name is STRING.\n\
  1520. If there is none, one is created by this function and returned.\n\
  1521. A second optional argument specifies the obarray to use;\n\
  1522. it defaults to the value of `obarray'.")
  1523.   (str, obarray)
  1524.      Lisp_Object str, obarray;
  1525. {
  1526.   register Lisp_Object tem, sym, *ptr;
  1527.  
  1528.   if (NILP (obarray)) obarray = Vobarray;
  1529.   obarray = check_obarray (obarray);
  1530.  
  1531.   CHECK_STRING (str, 0);
  1532.  
  1533.   tem = oblookup (obarray, XSTRING (str)->data, XSTRING (str)->size);
  1534.   if (XTYPE (tem) != Lisp_Int)
  1535.     return tem;
  1536.  
  1537.   if (!NILP (Vpurify_flag))
  1538.     str = Fpurecopy (str);
  1539.   sym = Fmake_symbol (str);
  1540.  
  1541.   ptr = &XVECTOR (obarray)->contents[XINT (tem)];
  1542.   if (XTYPE (*ptr) == Lisp_Symbol)
  1543.     XSYMBOL (sym)->next = XSYMBOL (*ptr);
  1544.   else
  1545.     XSYMBOL (sym)->next = 0;
  1546.   *ptr = sym;
  1547.   return sym;
  1548. }
  1549.  
  1550. DEFUN ("intern-soft", Fintern_soft, Sintern_soft, 1, 2, 0,
  1551.   "Return the canonical symbol whose name is STRING, or nil if none exists.\n\
  1552. A second optional argument specifies the obarray to use;\n\
  1553. it defaults to the value of `obarray'.")
  1554.   (str, obarray)
  1555.      Lisp_Object str, obarray;
  1556. {
  1557.   register Lisp_Object tem;
  1558.  
  1559.   if (NILP (obarray)) obarray = Vobarray;
  1560.   obarray = check_obarray (obarray);
  1561.  
  1562.   CHECK_STRING (str, 0);
  1563.  
  1564.   tem = oblookup (obarray, XSTRING (str)->data, XSTRING (str)->size);
  1565.   if (XTYPE (tem) != Lisp_Int)
  1566.     return tem;
  1567.   return Qnil;
  1568. }
  1569.  
  1570. Lisp_Object
  1571. oblookup (obarray, ptr, size)
  1572.      Lisp_Object obarray;
  1573.      register char *ptr;
  1574.      register int size;
  1575. {
  1576.   int hash, obsize;
  1577.   register Lisp_Object tail;
  1578.   Lisp_Object bucket, tem;
  1579.  
  1580.   if (XTYPE (obarray) != Lisp_Vector ||
  1581.       (obsize = XVECTOR (obarray)->size) == 0)
  1582.     {
  1583.       obarray = check_obarray (obarray);
  1584.       obsize = XVECTOR (obarray)->size;
  1585.     }
  1586.   /* Combining next two lines breaks VMS C 2.3.  */
  1587.   hash = hash_string (ptr, size);
  1588.   hash %= obsize;
  1589.   bucket = XVECTOR (obarray)->contents[hash];
  1590.   if (XFASTINT (bucket) == 0)
  1591.     ;
  1592.   else if (XTYPE (bucket) != Lisp_Symbol)
  1593.     error ("Bad data in guts of obarray"); /* Like CADR error message */
  1594.   else for (tail = bucket; ; XSET (tail, Lisp_Symbol, XSYMBOL (tail)->next))
  1595.       {
  1596.     if (XSYMBOL (tail)->name->size == size &&
  1597.         !bcmp (XSYMBOL (tail)->name->data, ptr, size))
  1598.       return tail;
  1599.     else if (XSYMBOL (tail)->next == 0)
  1600.       break;
  1601.       }
  1602.   XSET (tem, Lisp_Int, hash);
  1603.   return tem;
  1604. }
  1605.  
  1606. static int
  1607. hash_string (ptr, len)
  1608.      unsigned char *ptr;
  1609.      int len;
  1610. {
  1611.   register unsigned char *p = ptr;
  1612.   register unsigned char *end = p + len;
  1613.   register unsigned char c;
  1614.   register int hash = 0;
  1615.  
  1616.   while (p != end)
  1617.     {
  1618.       c = *p++;
  1619.       if (c >= 0140) c -= 40;
  1620.       hash = ((hash<<3) + (hash>>28) + c);
  1621.     }
  1622.   return hash & 07777777777;
  1623. }
  1624.  
  1625. void
  1626. map_obarray (obarray, fn, arg)
  1627.      Lisp_Object obarray;
  1628.      _VOID_ (*fn) _P_((Lisp_Object tail, Lisp_Object arg));
  1629.      Lisp_Object arg;
  1630. {
  1631.   register int i;
  1632.   register Lisp_Object tail;
  1633.   CHECK_VECTOR (obarray, 1);
  1634.   for (i = XVECTOR (obarray)->size - 1; i >= 0; i--)
  1635.     {
  1636.       tail = XVECTOR (obarray)->contents[i];
  1637.       if (XFASTINT (tail) != 0)
  1638.     while (1)
  1639.       {
  1640.         (*fn) (tail, arg);
  1641.         if (XSYMBOL (tail)->next == 0)
  1642.           break;
  1643.         XSET (tail, Lisp_Symbol, XSYMBOL (tail)->next);
  1644.       }
  1645.     }
  1646. }
  1647.  
  1648. _VOID_
  1649. mapatoms_1 (sym, function)
  1650.      Lisp_Object sym, function;
  1651. {
  1652.   call1 (function, sym);
  1653. }
  1654.  
  1655. DEFUN ("mapatoms", Fmapatoms, Smapatoms, 1, 2, 0,
  1656.   "Call FUNCTION on every symbol in OBARRAY.\n\
  1657. OBARRAY defaults to the value of `obarray'.")
  1658.   (function, obarray)
  1659.      Lisp_Object function, obarray;
  1660. {
  1661.   if (NILP (obarray)) obarray = Vobarray;
  1662.   obarray = check_obarray (obarray);
  1663.  
  1664.   map_obarray (obarray, mapatoms_1, function);
  1665.   return Qnil;
  1666. }
  1667.  
  1668. #define OBARRAY_SIZE 509
  1669.  
  1670. void
  1671. init_obarray ()
  1672. {
  1673.   Lisp_Object oblength;
  1674.   int hash;
  1675.   Lisp_Object *tem;
  1676.  
  1677.   XFASTINT (oblength) = OBARRAY_SIZE;
  1678.  
  1679.   Qnil = Fmake_symbol (make_pure_string ("nil", 3));
  1680.   Vobarray = Fmake_vector (oblength, make_number (0));
  1681.   initial_obarray = Vobarray;
  1682.   staticpro (&initial_obarray);
  1683.   /* Intern nil in the obarray */
  1684.   /* These locals are to kludge around a pyramid compiler bug. */
  1685.   hash = hash_string ("nil", 3);
  1686.   /* Separate statement here to avoid VAXC bug. */
  1687.   hash %= OBARRAY_SIZE;
  1688.   tem = &XVECTOR (Vobarray)->contents[hash];
  1689.   *tem = Qnil;
  1690.  
  1691.   Qunbound = Fmake_symbol (make_pure_string ("unbound", 7));
  1692.   XSYMBOL (Qnil)->function = Qunbound;
  1693.   XSYMBOL (Qunbound)->value = Qunbound;
  1694.   XSYMBOL (Qunbound)->function = Qunbound;
  1695.  
  1696.   Qt = intern ("t");
  1697.   XSYMBOL (Qnil)->value = Qnil;
  1698.   XSYMBOL (Qnil)->plist = Qnil;
  1699.   XSYMBOL (Qt)->value = Qt;
  1700.  
  1701.   /* Qt is correct even if CANNOT_DUMP.  loadup.el will set to nil at end.  */
  1702.   Vpurify_flag = Qt;
  1703.  
  1704.   Qvariable_documentation = intern ("variable-documentation");
  1705.  
  1706.   read_buffer_size = 100;
  1707.   read_buffer = (char *) malloc (read_buffer_size);
  1708. }
  1709.  
  1710. void
  1711. defsubr (sname)
  1712.      struct Lisp_Subr *sname;
  1713. {
  1714.   Lisp_Object sym;
  1715.   sym = intern (sname->symbol_name);
  1716.   XSET (XSYMBOL (sym)->function, Lisp_Subr, sname);
  1717. }
  1718.  
  1719. #ifdef NOTDEF /* use fset in subr.el now */
  1720. void
  1721. defalias (sname, string)
  1722.      struct Lisp_Subr *sname;
  1723.      char *string;
  1724. {
  1725.   Lisp_Object sym;
  1726.   sym = intern (string);
  1727.   XSET (XSYMBOL (sym)->function, Lisp_Subr, sname);
  1728. }
  1729. #endif /* NOTDEF */
  1730.  
  1731. /* New replacement for DefIntVar; it ignores the doc string argument
  1732.    on the assumption that make-docfile will handle that.  */
  1733. /* Define an "integer variable"; a symbol whose value is forwarded
  1734.  to a C variable of type int.  Sample call: */
  1735.   /* DEFVARINT ("indent-tabs-mode", &indent_tabs_mode, "Documentation");  */
  1736.  
  1737. void
  1738. defvar_int (namestring, address, doc)
  1739.      char *namestring;
  1740.      int *address;
  1741.      char *doc;
  1742. {
  1743.   Lisp_Object sym;
  1744.   sym = intern (namestring);
  1745.   XSET (XSYMBOL (sym)->value, Lisp_Intfwd, address);
  1746. }
  1747.  
  1748. /* Similar but define a variable whose value is T if address contains 1,
  1749.  NIL if address contains 0 */
  1750.  
  1751. void
  1752. defvar_bool (namestring, address, doc)
  1753.      char *namestring;
  1754.      int *address;
  1755.      char *doc;
  1756. {
  1757.   Lisp_Object sym;
  1758.   sym = intern (namestring);
  1759.   XSET (XSYMBOL (sym)->value, Lisp_Boolfwd, address);
  1760. }
  1761.  
  1762. /* Similar but define a variable whose value is the Lisp Object stored at address. */
  1763.  
  1764. void
  1765. defvar_lisp (namestring, address, doc)
  1766.      char *namestring;
  1767.      Lisp_Object *address;
  1768.      char *doc;
  1769. {
  1770.   Lisp_Object sym;
  1771.   sym = intern (namestring);
  1772.   XSET (XSYMBOL (sym)->value, Lisp_Objfwd, address);
  1773.   staticpro (address);
  1774. }
  1775.  
  1776. /* Similar but don't request gc-marking of the C variable.
  1777.    Used when that variable will be gc-marked for some other reason,
  1778.    since marking the same slot twice can cause trouble with strings.  */
  1779.  
  1780. void
  1781. defvar_lisp_nopro (namestring, address, doc)
  1782.      char *namestring;
  1783.      Lisp_Object *address;
  1784.      char *doc;
  1785. {
  1786.   Lisp_Object sym;
  1787.   sym = intern (namestring);
  1788.   XSET (XSYMBOL (sym)->value, Lisp_Objfwd, address);
  1789. }
  1790.  
  1791. #ifndef standalone
  1792.  
  1793. /* Similar but define a variable whose value is the Lisp Object stored in
  1794.  the current buffer.  address is the address of the slot in the buffer that is current now. */
  1795.  
  1796. void
  1797. defvar_per_buffer (namestring, address, type, doc)
  1798.      char *namestring;
  1799.      Lisp_Object *address;
  1800.      Lisp_Object type;
  1801.      char *doc;
  1802. {
  1803.   Lisp_Object sym;
  1804.   int offset;
  1805.   extern struct buffer buffer_local_symbols;
  1806.  
  1807.   sym = intern (namestring);
  1808.   offset = (char *)address - (char *)current_buffer;
  1809.  
  1810.   XSET (XSYMBOL (sym)->value, Lisp_Buffer_Objfwd,
  1811.     (Lisp_Object *) offset);
  1812.   *(Lisp_Object *)(offset + (char *)&buffer_local_symbols) = sym;
  1813.   *(Lisp_Object *)(offset + (char *)&buffer_local_types) = type;
  1814.   if (*(int *)(offset + (char *)&buffer_local_flags) == 0)
  1815.     /* Did a DEFVAR_PER_BUFFER without initializing the corresponding
  1816.        slot of buffer_local_flags */
  1817.     abort ();
  1818. }
  1819.  
  1820. #endif /* standalone */
  1821.  
  1822. _VOID_
  1823. init_lread ()
  1824. {
  1825.   char *normal;
  1826.  
  1827.   /* Compute the default load-path.  */
  1828. #ifdef CANNOT_DUMP
  1829.   normal = PATH_LOADSEARCH;
  1830. #ifdef    WINDOWSNT
  1831.   Vload_path = decode_env_path ("PATH", normal);
  1832. #else /* !WINDOWSNT */
  1833.   Vload_path = decode_env_path (0, normal);
  1834. #endif /* !WINDOWSNT */
  1835. #else
  1836.   if (NILP (Vpurify_flag))
  1837.     normal = PATH_LOADSEARCH;
  1838.   else
  1839.     normal = PATH_DUMPLOADSEARCH;
  1840.  
  1841.   /* In a dumped Emacs, we normally have to reset the value of
  1842.      Vload_path from PATH_LOADSEARCH, since the value that was dumped
  1843.      uses ../lisp, instead of the path of the installed elisp
  1844.      libraries.  However, if it appears that Vload_path was changed
  1845.      from the default before dumping, don't override that value.  */
  1846.   if (initialized)
  1847.     {
  1848.       Lisp_Object dump_path;
  1849.  
  1850.       dump_path = decode_env_path (0, PATH_DUMPLOADSEARCH);
  1851.       if (! NILP (Fequal (dump_path, Vload_path)))
  1852.     Vload_path = decode_env_path (0, normal);
  1853.     }
  1854.   else
  1855.     Vload_path = decode_env_path (0, normal);
  1856. #endif
  1857.  
  1858.   /* Warn if dirs in the *standard* path don't exist.  */
  1859.   {
  1860.     Lisp_Object path_tail;
  1861.  
  1862.     for (path_tail = Vload_path;
  1863.      !NILP (path_tail);
  1864.      path_tail = XCONS (path_tail)->cdr)
  1865.       {
  1866.     Lisp_Object dirfile;
  1867.     dirfile = Fcar (path_tail);
  1868.     if (XTYPE (dirfile) == Lisp_String)
  1869.       {
  1870.         dirfile = Fdirectory_file_name (dirfile);
  1871.         if (access (XSTRING (dirfile)->data, 0) < 0)
  1872.           printf ("Warning: lisp library (%s) does not exist.\n",
  1873.               XSTRING (Fcar (path_tail))->data);
  1874.       }
  1875.       }
  1876.   }
  1877.  
  1878.   /* If the EMACSLOADPATH environment variable is set, use its value.
  1879.      This doesn't apply if we're dumping.  */
  1880. #ifdef WINDOWSNT
  1881.   // How can this not be this?
  1882.   if (!NILP (Vpurify_flag)
  1883.       && egetenv ("EMACSLOADPATH"))
  1884.       Vload_path = decode_env_path ("EMACSLOADPATH", normal);
  1885. #else
  1886.   if (NILP (Vpurify_flag)
  1887.       && egetenv ("EMACSLOADPATH"))
  1888.     Vload_path = decode_env_path ("EMACSLOADPATH", normal);
  1889. #endif
  1890.   Vvalues = Qnil;
  1891.   load_in_progress = 0;
  1892. }
  1893.  
  1894. void
  1895. syms_of_lread ()
  1896. {
  1897.   defsubr (&Sread);
  1898.   defsubr (&Sread_from_string);
  1899.   defsubr (&Sintern);
  1900.   defsubr (&Sintern_soft);
  1901.   defsubr (&Sload);
  1902.   defsubr (&Seval_buffer);
  1903.   defsubr (&Seval_region);
  1904.   defsubr (&Sread_char);
  1905.   defsubr (&Sread_char_exclusive);
  1906.   defsubr (&Sread_event);
  1907.   defsubr (&Sget_file_char);
  1908.   defsubr (&Smapatoms);
  1909.  
  1910.   DEFVAR_LISP ("obarray", &Vobarray,
  1911.     "Symbol table for use by `intern' and `read'.\n\
  1912. It is a vector whose length ought to be prime for best results.\n\
  1913. The vector's contents don't make sense if examined from Lisp programs;\n\
  1914. to find all the symbols in an obarray, use `mapatoms'.");
  1915.  
  1916.   DEFVAR_LISP ("values", &Vvalues,
  1917.     "List of values of all expressions which were read, evaluated and printed.\n\
  1918. Order is reverse chronological.");
  1919.  
  1920.   DEFVAR_LISP ("standard-input", &Vstandard_input,
  1921.     "Stream for read to get input from.\n\
  1922. See documentation of `read' for possible values.");
  1923.   Vstandard_input = Qt;
  1924.  
  1925.   DEFVAR_LISP ("load-path", &Vload_path,
  1926.     "*List of directories to search for files to load.\n\
  1927. Each element is a string (directory name) or nil (try default directory).\n\
  1928. Initialized based on EMACSLOADPATH environment variable, if any,\n\
  1929. otherwise to default specified by file `paths.h' when Emacs was built.");
  1930.  
  1931.   DEFVAR_BOOL ("load-in-progress", &load_in_progress,
  1932.     "Non-nil iff inside of `load'.");
  1933.  
  1934.   DEFVAR_LISP ("after-load-alist", &Vafter_load_alist,
  1935.     "An alist of expressions to be evalled when particular files are loaded.\n\
  1936. Each element looks like (FILENAME FORMS...).\n\
  1937. When `load' is run and the file-name argument is FILENAME,\n\
  1938. the FORMS in the corresponding element are executed at the end of loading.\n\n\
  1939. FILENAME must match exactly!  Normally FILENAME is the name of a library,\n\
  1940. with no directory specified, since that is how `load' is normally called.\n\
  1941. An error in FORMS does not undo the load,\n\
  1942. but does prevent execution of the rest of the FORMS.");
  1943.   Vafter_load_alist = Qnil;
  1944.  
  1945.   DEFVAR_LISP ("load-history", &Vload_history,
  1946.     "Alist mapping source file names to symbols and features.\n\
  1947. Each alist element is a list that starts with a file name,\n\
  1948. except for one element (optional) that starts with nil and describes\n\
  1949. definitions evaluated from buffers not visiting files.\n\
  1950. The remaining elements of each list are symbols defined as functions\n\
  1951. or variables, and cons cells `(provide . FEATURE)' and `(require . FEATURE)'.");
  1952.   Vload_history = Qnil;
  1953.  
  1954.   DEFVAR_LISP ("current-load-list", &Vcurrent_load_list,
  1955.     "Used for internal purposes by `load'.");
  1956.   Vcurrent_load_list = Qnil;
  1957.  
  1958.   Qcurrent_load_list = intern ("current-load-list");
  1959.   staticpro (&Qcurrent_load_list);
  1960.  
  1961.   Qstandard_input = intern ("standard-input");
  1962.   staticpro (&Qstandard_input);
  1963.  
  1964.   Qread_char = intern ("read-char");
  1965.   staticpro (&Qread_char);
  1966.  
  1967.   Qget_file_char = intern ("get-file-char");
  1968.   staticpro (&Qget_file_char);
  1969.  
  1970.   Qascii_character = intern ("ascii-character");
  1971.   staticpro (&Qascii_character);
  1972.  
  1973.   Qload = intern ("load");
  1974.   staticpro (&Qload);
  1975. }
  1976.